package com.tools.acceleratecore.xlib.tool.impl;

import com.tools.acceleratecore.xlib.tool.intf.IDelayTool;

public class DelayTool implements IDelayTool {
    private long mTimeBefore = 0L;
    private long mTimeSpacing = 0L;

    public DelayTool() {
        this._init();
    }

    private void _init() {
    }

    public void setTimeSpacing(long lTimeSpacing) {
        this.mTimeSpacing = lTimeSpacing;
    }

    public boolean isExceedSpacing(boolean bUpdateTimeBefore) {
        long lTimeCur = System.currentTimeMillis();
        if (lTimeCur - this.mTimeBefore > this.mTimeSpacing) {
            if (bUpdateTimeBefore) {
                this.mTimeBefore = lTimeCur;
            }

            return true;
        } else {
            return false;
        }
    }

    public void updateTimeBefore() {
        this.mTimeBefore = System.currentTimeMillis();
    }
}
